package com.shareppy.normanapitest.lexic;

import com.shareppy.normanapitest.lexic.lexemes.LexemeState;

public class Lexeme implements Cloneable {

	private LexemeType type;

	protected StringBuilder content;

	public Lexeme(LexemeType type) {
		this.type = type;
		content = new StringBuilder();
	}

	public Lexeme(char ch, LexemeType type) {
		this(type);
		content.append(ch);
	}

	public void append(char ch) {
		content.append(ch);
	}

	public void setType(LexemeType type) {
		this.type = type;
	}

	public LexemeType getType() {
		return type;
	}

	public void setContent(char ch) {
		this.content = new StringBuilder(String.valueOf(ch));
	}

	public String toString() {
		return type + "=" +content.toString();
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		return super.clone();
	}

	public static LexemeType computeType(char ch) {
		if (ch == '\'' || ch == '"') {
			return LexemeType.LITERAL;
		}
		return LexemeType.NONE;
	}

	public LexemeState supports(char ch) {
		return LexemeState.NONE;
	}
}